package com.gzlg.hospital.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gzlg.hospital.dao.DoctorDao;
import com.gzlg.hospital.pojo.*;
import com.gzlg.hospital.pojo.query.hQuery;
import com.gzlg.hospital.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class DoctorServiceImpl implements DoctorService {
    @Autowired
    private DoctorDao doctorDao;

    //根据id查医生
    @Override
    public Doctor getDoctorById(Integer id) {
        return doctorDao.getDoctorById(id);
    }
    //医生登陆
    @Override
    public Doctor getDoctorByAccount(String account) {
        return doctorDao.getDoctorByAccount(account);
    }
    //护士处理挂号
    @Override
    public PageInfo<Registration> listRegistration(hQuery hQuery) {
        PageHelper.startPage(hQuery.getPageNum(), hQuery.getPageSize());
        return new PageInfo<Registration>(doctorDao.listRegistration());
    }
    //医生处理预约
    @Override
    public PageInfo<Appointment_details> listAppointmentDetailsByDoctorId(Integer doctor_id,hQuery hQuery) {
        PageHelper.startPage(hQuery.getPageNum(), hQuery.getPageSize());
        return new PageInfo<Appointment_details>(doctorDao.listAppointmentDetailsByDoctorId(doctor_id));
    }
    //医生查看所以病历

    @Override
    public PageInfo<Medical_record> listMedicalRecord(hQuery hQuery) {
        PageHelper.startPage(hQuery.getPageNum(), hQuery.getPageSize());
        return new PageInfo<Medical_record>(doctorDao.listMedicalRecord());
    }
    //医生通过患者id查看所有病历

    @Override
    public PageInfo<Medical_record> listMedicalRecordByPatientId(Integer patient_id, hQuery hQuery) {
        PageHelper.startPage(hQuery.getPageNum(), hQuery.getPageSize());
        return new PageInfo<Medical_record>(doctorDao.listMedicalRecordByPatientId(patient_id));
    }
    //医生通过挂号id查看处理
    @Override
    public PageInfo<Appointment_details> listAppointmentDetailsByRegistrationIdDoctorId(Map<String, Integer> map, hQuery hQuery) {
        PageHelper.startPage(hQuery.getPageNum(), hQuery.getPageSize());
        return new PageInfo<Appointment_details>(doctorDao.listAppointmentDetailsByRegistrationIdDoctorId(map));
    }
    //查找患者信息
    @Override
    public Patient getPatientById(Integer patient_id) {
        return doctorDao.getPatientById(patient_id);
    }
    //查找挂号信息
    @Override
    public Registration getRegistrationById(Integer registration_id) {
        return doctorDao.getRegistrationById(registration_id);
    }
    //护士处理挂号信息

    @Override
    public Boolean updateRegistration(Map<String, Object> map) {
        return doctorDao.updateRegistration(map);
    }

    @Override
    public Boolean addAppointmentDetails(Appointment_details appointment_details) {
        return doctorDao.addAppointmentDetails(appointment_details);
    }
    //通过科室获得房间号
    @Override
    public List<Consultation_room> getRoomsByDepartment(String department) {
        return doctorDao.RoomNyDepartment(department);
    }
    //添加病历

    @Override
    public Boolean addMedicalRecord(Medical_record medical_record) {
        return doctorDao.addMedicalRecord(medical_record);
    }

    @Override
    public Boolean addMedicalRecord2(Medical_record medical_record) {
        return doctorDao.addMedicalRecord2(medical_record);
    }

    @Override
    public Boolean updateAppointmentDetails(Integer registration_id) {
        return doctorDao.updateAppointmentDetails(registration_id);
    }

    @Override
    public Boolean updateRegistrationStatus(Integer id) {
        return doctorDao.updateRegistrationStatus(id);
    }
}
